package com.example.businessserver.controller;


import com.example.businessserver.entities.Business;
import com.example.businessserver.service.BusinessService;
import com.example.entities.Food;
import com.example.server_engineer.controller.AbstractTypedController;
import com.example.server_engineer.controller.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author Administrator
 */
@RestController
@Tag(name = "商家控制器")
@RequestMapping(value="business")
public class BusinessController extends AbstractTypedController<Business, Integer> {

    BusinessService bsvc;

    BusinessController(BusinessService businessService){
        this.svcContext = businessService;
        this.bsvc = businessService;
    }

    @Operation(summary = "按id检索商家接口")
    @GetMapping("/find/{id}")
    public Business getBusinessById(@PathVariable Integer id){
        return bsvc.getById(id);
    }

    @Operation(summary = "查看商家的食物列表")
    @GetMapping("/query/business_detail")
    public R queryBusinessInfo(String name){
        return bsvc.queryFoodByBusinessName(name);
//        Result result;
//        List<Food> foodlist = bsvc.queryFoodByBusinessName(name);
//        result = ResultGenerator.getSuccessResult(foodlist);
//        return result;
    }

//    @PostMapping("/setImg")
//    @Operation(summary = "插入图片")
//    public String setImgByBusinessId(Integer id, MultipartFile file){
//        return bsvc.setImgByBusinessId(id,file);
//    }
}
